package algorithm_learn.random;
import algorithm_learn.dataStructure.Code_LinkedListToQueueAndStack.MyQueue ;

import java.util.LinkedList;
import java.util.Queue;


public class Code_testStackAndQueue {
    /***
     * 对数期测试 队列
     */
    public static void testQueue(){
        MyQueue<Integer> myQueue = new MyQueue<>();
        Queue<Integer> queue = new LinkedList<>();
        int testTime = 5000000;
        int maxValue = 200000000;
        System.out.println("测试开始");
        for(int i =0;i<testTime;i++){
            //长度不等直接报错
            if(myQueue.isEmpty()!= queue.isEmpty()){
                System.out.println("error！");
            }
            if(myQueue.getSize()!= queue.size()){
                System.out.println("error！");
            }
            double decide = Math.random();
            if(decide < 0.33){
                int num = (int) (Math.random()*maxValue);
                myQueue.offer(num);
                queue.offer(num);
            }else if(decide < 0.66){
                int num = (int) (Math.random()*maxValue);
                myQueue.poll();
                queue.poll();
            }
        }
        System.out.println("successful!");
    }

    public static void main(String[] args) {
        testQueue();
    }
}
